package com.apexsoft.front.common.support;

import com.alibaba.fastjson.JSONObject;

import java.util.List;

/**
 * Created by lsj on 2017/7/10.
 */
public class Result {

    public static final String CODE       = "code";
    public static final String NOTE       = "note";
    public static final String COUNT      = "count";
    public static final String TOTAL      = "total";
    public static final String OBJECT     = "object";
    public static final String PAGE_SIZE  = "pageSize";
    public static final String PAGE_NUM   = "pageNum";
    public static final String RECORDS    = "records";
    //for easyui list key:rows
    public static final String ROWS    = "rows";

    public static final int SC_0001 = 1;
    public static final int EC_1000 = -1;


    public static JSONObject commonListResult(List<?> list){
        JSONObject result = new JSONObject();
        if (list!=null) {

			result.put(Result.CODE, Result.SC_0001);
			result.put(Result.NOTE, "查询成功");
			result.put(Result.TOTAL, list.size());
			result.put(Result.ROWS, list);
		}else{
			result.put(Result.CODE, Result.EC_1000);
			result.put(Result.NOTE, "查询失败");
		}
		return result;
    }
}
